package com.example.kick.designpattern;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Student {
    public String getName() {
        return "lee";
    }

    public static void main(String[] args) {
        Class c = Student.class;
        Object obj = null;
        String name = null;
        try {
            obj = c.newInstance();

            Method[] ms = c.getMethods();
            Method method = c.getDeclaredMethod("getName", null);
            name = (String) method.invoke(obj, null);
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
        System.out.println(name);
    }

}
